package BioServerAllAccept;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class SocketHandler implements Runnable {

    private Socket socket;

    public SocketHandler(Socket socket){
        this.socket = socket;
    }

    @Override
    public void run() {
        InputStream in = null;
        OutputStream out = null;
        try {
            in = socket.getInputStream();
            int len = 0;
            byte[] req = new byte[1024];
            while((len=in.read(req))>0){
                System.out.println(new String(req,0,len));

                //业务处理
                out = socket.getOutputStream();
                out.write("success".getBytes());
                System.out.println("end");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
